package com.ha.auto_skip.adapter;

import android.content.Context;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.viewbinding.ViewBinding;

import com.ha.auto_skip.bean.AppInfoBean;
import com.ha.auto_skip.bean.JumpBean;
import com.ha.auto_skip.databinding.AdapterAppInfoBinding;
import com.ha.auto_skip.databinding.AdapterJumpInfoBinding;
import com.xinkao.skmvp.adapter.SkRecyclerViewAdapter;
import com.xinkao.skmvp.adapter.SkRecyclerViewHolder;

public class JumpAdapter extends SkRecyclerViewAdapter<JumpBean> {
    @Override
    protected ViewBinding getLayout(Context context, int viewType) {
        return AdapterJumpInfoBinding.inflate(LayoutInflater.from(context));
    }

    @Override
    protected SkRecyclerViewHolder<JumpBean> getHolder(@NonNull ViewBinding binding, int viewType) {
        return new Holder(binding);
    }

    static class Holder extends SkRecyclerViewHolder<JumpBean> {

        AdapterJumpInfoBinding binding;

        public Holder(@NonNull ViewBinding binding) {
            super(binding);

            this.binding = (AdapterJumpInfoBinding) binding;
        }

        @Override
        public void setData(@NonNull JumpBean bean, int position) {
            binding.label.setText(bean.getLabel());
            binding.packageName.setText(bean.getPackage_name());
            binding.key.setText(String.format("%s %s", bean.getKey(), bean.getFuzzy() ? "（模糊）" : ""));
            binding.time.setText(String.valueOf(bean.getTime()));
        }
    }
}
